<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <%@include file="/view/common/head.jsp" %>
    <link rel="stylesheet" href="static/css/index.css">
    <title>书城首页</title>
</head>
<body>
<div class="content">
    <div class="top">
        <div class="left_top">
            <a href="index.jsp">
                <img src="static/image/logo.jpeg" alt="">
            </a>
        </div>
        <div class="right_top">

            <c:if test="${empty sessionScope.user}">
                <a href="view/user/login.jsp">登录</a>
                <span>|</span>
                <a href="view/user/register.jsp">注册</a>
            </c:if>
            <c:if test="${not empty sessionScope.user}">
                <span>欢迎</span>
                <span style="font-size: 20px;color: red;margin: 0 10px">${sessionScope.user.username}</span><span>光临荒岛书店</span>
                <a href="view/user/register.jsp">我的订单</a>
                <a href="userServlet?action=loginOut">注销</a>
            </c:if>
            <a href="view/cart/cart.jsp">购物车管理</a>
            <a href="view/manager/manager.jsp">后台管理</a>
        </div>
    </div>
    <div class="middle">
        <div class="search">
            <form action="client/clientServlet" method="get">
                <span>价格：</span>
                <input type="hidden" name="action" value="pageByPrice">
                <input type="text" name="min" value="${param.min}">元&nbsp;-&nbsp;
                <input type="text" name="max" value="${param.max}">&nbsp;元&nbsp;
                <button type="submit">查询</button>
            </form>
        </div>
        <div>您的购物车中有${sessionScope.cart.totalCount}件商品</div>
        <c:if test="${not empty sessionScope.lastName}">
            <div>您刚将 <span style="color: red">${sessionScope.lastName}</span>加入到了购物车中</div>
        </c:if>

        <div class="book_info">
            <c:forEach items="${requestScope.page.items}" var="book">
                <div class="info">
                    <form action="cartServlet?action=addItem" method="post">
                        <img src="${book.imgPath}" alt="">
                        <p>书名：${book.name}</p>
                        <input type="hidden" name="id" value="${book.id}">
                        <p>作者：${book.author}</p>
                        <p>价格：￥ ${book.price}</p>
                        <p>销量：${book.sales}</p>
                        <p>库存：${book.stock}</p>
                        <button type="submit">加入购物车</button>
                    </form>
                </div>

            </c:forEach>
        </div>
        <%@include file="/view/common/page_nav.jsp" %>
    </div>
</div>
<%@include file="/view/common/footer.jsp" %>
</body>
</html>